﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web;

namespace AAA.Web
{
    public class DialogHelper
    {
        public static void ShowMessageBox(string strMessage)
        {
            ShowMessageBox(strMessage, null);
        }
        public static void ShowMessageBox(string strMessage, string strRedirect)
        {
            string strScript;
            string strDisplayMessage;
            if (strMessage == null)
                return;

            //strDisplayMessage = strMessage.Replace("'", "\'");//.Replace(Environment.NewLine, "\n");
            strDisplayMessage = HttpUtility.HtmlEncode(strMessage).Replace("\n", "\\\n").Replace("'", "");
            strScript = string.Format("alert(\"{0}\");", strDisplayMessage);

            if (strRedirect != null)
                strScript += string.Format("\nwindow.location=\"{0}\";", strRedirect);

            ControlHelper.ExecuteScript("self", strScript, true);
        }

    }
}
